home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Compilers⁄Interps / GCC-2.3.3r12 / Sources / gvarargs.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-02-05  |  4.1 KB  |  170 lines  |  [TEXT/MPS ]

  1. /*   Copyright (C) 1989, 1990 Apple Computer, Inc.  */
  2.  
  3. #ifdef MPW
  4. /*Hack our own varargs*/
  5. #ifndef __va_list__
  6. #define __va_list__
  7. typedef char *va_list;
  8. #endif
  9. #define va_dcl int va_alist;
  10. #define va_start(list) list = (char *) &va_alist
  11. #define va_end(list)
  12. #define va_arg(list,mode) ((mode *)(list += sizeof(mode)))[-1]
  13. #else
  14. #ifndef __GNUC__
  15. /* Use the system's macros with the system's compiler.  */
  16. #include <varargs.h>
  17. #else
  18. /* Record that this is varargs.h; this turns off stdarg.h.  */
  19.  
  20. #ifndef _VARARGS_H
  21. #define _VARARGS_H
  22.  
  23. #ifdef __sparc__
  24. #include <va-sparc.h>
  25. #else
  26. #ifdef __spur__
  27. #include <va-spur.h>
  28. #else
  29. #ifdef __mips__
  30. #include <va-mips.h>
  31. #else
  32. #ifdef __i860__
  33. #include <va-i860.h>
  34. #else
  35. #ifdef __pyr__
  36. #include <va-pyr.h>
  37. #else
  38. #ifdef __m88k__
  39. #include <va-m88k.h>
  40. #else
  41. #if defined(__hppa__) || defined(hp800)
  42. #include <va-pa.h>
  43. #else
  44. #ifdef __i960__
  45. #include <va-i960.h>
  46. #else
  47. #ifdef __alpha__
  48. #include <va-alpha.h>
  49. #else
  50.  
  51. #ifdef __NeXT__
  52.  
  53. /* On Next, erase any vestiges of stdarg.h.  */
  54.  
  55. #ifdef _ANSI_STDARG_H_
  56. #define _VA_LIST_
  57. #endif
  58. #define _ANSI_STDARG_H_ 
  59.  
  60. #undef va_alist
  61. #undef va_dcl
  62. #undef va_list
  63. #undef va_start
  64. #undef va_end
  65. #undef __va_rounded_size
  66. #undef va_arg
  67. #endif  /* __NeXT__ */
  68.  
  69. /* In GCC version 2, we want an ellipsis at the end of the declaration
  70.    of the argument list.  GCC version 1 can't parse it.  */
  71.  
  72. #if __GNUC__ > 1
  73. #define __va_ellipsis ...
  74. #else
  75. #define __va_ellipsis
  76. #endif
  77.  
  78. /* These macros implement traditional (non-ANSI) varargs
  79.    for GNU C.  */
  80.  
  81. #define va_alist  __builtin_va_alist
  82. /* The ... causes current_function_varargs to be set in cc1.  */
  83. #define va_dcl    int __builtin_va_alist; __va_ellipsis
  84.  
  85. /* Define __gnuc_va_list, just as in gstdarg.h.  */
  86.  
  87. #ifndef __GNUC_VA_LIST
  88. #define __GNUC_VA_LIST
  89. #if defined(__svr4__) || defined(_AIX) || defined(_M_UNIX)
  90. typedef char *__gnuc_va_list;
  91. #else
  92. typedef void *__gnuc_va_list;
  93. #endif
  94. #endif
  95.  
  96. #define va_start(AP)  AP=(char *) &__builtin_va_alist
  97.  
  98. #define va_end(AP)
  99.  
  100. #define __va_rounded_size(TYPE)  \
  101.   (((sizeof (TYPE) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))
  102.  
  103. #if defined (__arm__) || defined (__i386__) || defined (__ns32000__) || defined (__vax__)
  104. /* This is for little-endian machines; small args are padded upward.  */
  105. #define va_arg(AP, TYPE)                        \
  106.  (AP = (__gnuc_va_list) ((char *) (AP) + __va_rounded_size (TYPE)),    \
  107.   *((TYPE *) (void *) ((char *) (AP) - __va_rounded_size (TYPE))))
  108. #else /* big-endian */
  109. /* This is for big-endian machines; small args are padded downward.  */
  110. #define va_arg(AP, TYPE)                        \
  111.  (AP = (__gnuc_va_list) ((char *) (AP) + __va_rounded_size (TYPE)),    \
  112.   *((TYPE *) (void *) ((char *) (AP) - ((sizeof (TYPE) < 4        \
  113.                      ? sizeof (TYPE)        \
  114.                      : __va_rounded_size (TYPE))))))
  115. #endif /* big-endian */
  116.  
  117. #endif /* not alpha */
  118. #endif /* not i960 */
  119. #endif /* not hppa */
  120. #endif /* not m88k */
  121. #endif /* not pyr */
  122. #endif /* not i860 */
  123. #endif /* not mips */
  124. #endif /* not spur */
  125. #endif /* not sparc */
  126. #endif /* not _VARARGS_H */
  127.  
  128. #endif /* MPW */
  129. /* Define va_list from __gnuc_va_list.  */
  130.  
  131. #ifdef _HIDDEN_VA_LIST  /* On OSF1, this means varargs.h is "half-loaded".  */
  132. #undef _VA_LIST
  133. #endif
  134.  
  135. #ifdef __SVR4_2__
  136.  
  137. /* SVR4.2 uses _VA_LIST for an internal alias for va_list,
  138.    so we must avoid testing it and setting it here.  */
  139. #ifndef _VA_LIST_
  140. #define _VA_LIST_
  141. typedef __gnuc_va_list va_list;
  142. #endif /* _VA_LIST_ */
  143.  
  144. #else /* not __SVR4_2__ */
  145.  
  146. /* The macro _VA_LIST_ is the same thing used by this file in Ultrix.
  147.    But on BSD NET2 we must not test or define or undef it.
  148.    (Note that the comments in NET 2's ansi.h
  149.    are incorrect for _VA_LIST_--see stdio.h!)  */
  150. #if !defined (_VA_LIST_) || defined (__BSD_NET2__) || defined (____386BSD____)
  151. /* The macro _VA_LIST is used in SCO Unix 3.2.  */
  152. #ifndef _VA_LIST
  153. #if !(defined (__BSD_NET2__) || defined (____386BSD____))
  154. #define _VA_LIST_
  155. #endif
  156. #define _VA_LIST
  157. typedef __gnuc_va_list va_list;
  158. #endif /* not _VA_LIST */
  159. #endif /* not _VA_LIST_ */
  160.  
  161. #endif /* not __SVR4_2__ */
  162.  
  163. /* The next BSD release (if there is one) wants this symbol to be
  164.    undefined instead of _VA_LIST_.  */
  165. #ifdef _BSD_VA_LIST
  166. #undef _BSD_VA_LIST
  167. #endif
  168.  
  169. #endif /* __GNUC__ */
  170.